<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用户列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>昵称：</label>
                                <input type="text" name="nickname"/>
                            </li>
                            <li>
                                <label>手机号：</label>
                                <input type="text" name="phone"/>
                            </li>
                            <li>
                                <label>是否正常：</label>
                                <select name="isDisable">
                                    <option value="">所有</option>
                                    <option value="1">正常</option>
                                    <option value="0">封禁</option>
                                </select>
                            </li>
                            <li>
                                <label>等级：</label>
                                <input type="text" name="levelName"/>
                            </li>
                            <!--<li>
                                <label>父级邀请码：</label>
                                <input type="text" name="pCode"/>
                            </li>-->
                            <li>
                                <label>用户姓名：</label>
                                <input type="text" name="userName"/>
                            </li>
                            <li>
                                <label>身份证号：</label>
                                <input type="text" name="userIdcard"/>
                            </li>
                            <li>
                                <label>QQ号码：</label>
                                <input type="text" name="qqnum"/>
                            </li>
                            <li>
                                <label>用户省份：</label>
                                <input type="text" name="userProvince"/>
                            </li>
                            <li>
                                <label>用户城市：</label>
                                <input type="text" name="userCity"/>
                            </li>
                            <li>
                                <label>身份认证：</label>
                                <select name="isCheck">
                                    <option value="">所有</option>
                                    <option value="申请">申请</option>
                                    <option value="审核中">审核中</option>
                                    <option value="审核通过">审核通过</option>
                                    <option value="审核不通过">审核不通过</option>
                                </select>
                            </li>
                            <li>
                                <label>诚信认证：</label>
                                <select name="isHonestyCheck">
                                    <option value="">所有</option>
                                    <option value="申请">申请</option>
                                    <option value="审核中">审核中</option>
                                    <option value="审核通过">审核通过</option>
                                    <option value="审核不通过">审核不通过</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="jjyh:user:add">
                    <i class="fa fa-plus"></i> 添加
                </a>-->
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="jjyh:user:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
               <!-- <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="jjyh:user:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="jjyh:user:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('jjyh:user:edit')}]];
        var removeFlag = [[${@permission.hasPermi('jjyh:user:remove')}]];
        var prefix = ctx + "jjyh/user";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "用户",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '用户id',
                    visible: false
                },
                {
                    field: 'nickname',
                    title: '昵称'
                },
                {
                    field: 'headImg',
                    title: '头像',
                    formatter: function(value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                {
                    field: 'phone',
                    title: '用户手机号'
                },
                {
                    field: 'levelName',
                    title: '等级'
                },
               /* {
                    field: 'invitationCode',
                    title: '用户的邀请码'
                },
                {
                    field: 'pCode',
                    title: '父级邀请码'
                },
                {
                    field: 'shareUrl',
                    title: '分享连接'
                },*/
                {
                    field: 'collectionCodeWx',
                    title: '微信收款码',
                    formatter: function(value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                {
                    field: 'collectionCodeZfb',
                    title: '支付宝收款码',
                    formatter: function(value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                {
                    field: 'userName',
                    title: '用户姓名'
                },
                {
                    field: 'userIdcard',
                    title: '身份证号'
                },
                    {
                        field: 'isCheck',
                        title: '身份认证'
                    },
               /* {
                    field: 'qqnum',
                    title: 'QQ号码'
                },
                {
                    field: 'userBirthday',
                    title: '生日'
                },*/
                {
                    field: 'userProvince',
                    title: '用户省份'
                },
                {
                    field: 'userCity',
                    title: '用户城市'
                },
                /*{
                    field: 'password',
                    title: '登录密码'
                },


                {
                    field: 'disReason',
                    title: '拒绝原因'
                },
                {
                    field: 'wxpayId',
                    title: '微信openid'
                },
                {
                    field: 'wxImage',
                    title: '微信头像'
                },
                {
                    field: 'alipayId',
                    title: '支付宝id'
                },
                {
                    field: 'alipayImage',
                    title: '支付宝头像'
                },*/
                {
                    field: 'idcardImage',
                    title: '身份证正面',
                    formatter: function(value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                {
                    field: 'idcardBackimages',
                    title: '身份证反面',
                    formatter: function(value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                {
                    field: 'idcardHold',
                    title: '手持身份证',
                    formatter: function(value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                    {
                        field: 'isHonestyCheck',
                        title: '诚信认证'
                    },
                    {
                        field: 'isDisable',
                        title: '是否正常'
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.isDisable == '正常'){
                            actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="disableUser(\'' + row.id + '\')"><i class="fa fa-edit"></i>禁用</a> ');
                        }
                        if(row.isDisable == '封禁'){
                            actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="enableUser(\'' + row.id + '\')"><i class="fa fa-edit"></i>启用</a> ');
                        }
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="viewUser(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看</a> ');
                       /* actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');*/
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function disableUser(id) {
            $.ajax({
                type: "post",
                url: ctx + "jjyh/user/disableUser?id="+id,
                success: function(r) {
                    $.modal.msgSuccess("禁用成功");
                }
            });
            $.modal.reload();
        }

        function enableUser(id) {
            $.ajax({
                type: "post",
                url: ctx + "jjyh/user/enableUser?id="+id,
                success: function(r) {
                    $.modal.msgSuccess("解封成功");
                }
            });
            $.modal.reload();
        }

        function viewUser(id) {
            debugger;
            //$.modal.openNoBtn("查看活动",ctx+"lm/activity/view/"+id);
            var title="查看用户信息";
            var url=ctx+"jjyh/user/view/"+id;
            var width;
            var height;
            var callback;
            //如果是移动端，就使用自适应大小弹窗
            if ($.common.isMobile()) {
                width = 'auto';
                height = 'auto';
            }
            if ($.common.isEmpty(title)) {
                title = false;
            }
            if ($.common.isEmpty(url)) {
                url = "/404.html";
            }
            if ($.common.isEmpty(width)) {
                width = 800;
            }
            if ($.common.isEmpty(height)) {
                height = ($(window).height() - 50);
            }
            if ($.common.isEmpty(callback)) {
                callback = function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(index, layero);
                }
            }
            layer.open({
                type: 2,
                area: [width + 'px', height + 'px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: title,
                content: url,
                // 弹层外区域关闭
                shadeClose: true,
                yes: callback,
                cancel: function(index) {
                    return true;
                }
            });
        }

    </script>
</body>
</html>